package com.palace.saw.module.app.dal.mysql.banner;

import java.util.*;

import com.palace.saw.framework.common.pojo.PageResult;
import com.palace.saw.framework.mybatis.core.query.LambdaQueryWrapperX;
import com.palace.saw.framework.mybatis.core.mapper.BaseMapperX;
import com.palace.saw.module.app.dal.dataobject.banner.BannerDO;
import org.apache.ibatis.annotations.Mapper;
import com.palace.saw.module.app.controller.admin.banner.vo.*;

/**
 * Banner 广告位 Mapper
 *
 * @author saw
 */
@Mapper
public interface BannerMapper extends BaseMapperX<BannerDO> {

    default PageResult<BannerDO> selectPage(BannerPageReqVO reqVO) {
        return selectPage(reqVO, new LambdaQueryWrapperX<BannerDO>()
                .eqIfPresent(BannerDO::getTitle, reqVO.getTitle())
                .eqIfPresent(BannerDO::getPicUrl, reqVO.getPicUrl())
                .eqIfPresent(BannerDO::getUrl, reqVO.getUrl())
                .eqIfPresent(BannerDO::getStatus, reqVO.getStatus())
                .eqIfPresent(BannerDO::getSort, reqVO.getSort())
                .eqIfPresent(BannerDO::getPosition, reqVO.getPosition())
                .eqIfPresent(BannerDO::getMemo, reqVO.getMemo())
                .eqIfPresent(BannerDO::getBrowseCount, reqVO.getBrowseCount())
                .betweenIfPresent(BannerDO::getCreateTime, reqVO.getCreateTime())
                .orderByDesc(BannerDO::getId));
    }

}